#include "graphicsobjecteditor.h"
#include "../gameobjects/graphicsobject.h"
#include "widgets/editgraphicsobjectwidget.h"
#include "../application.h"
#include "../document.h"

GraphicsObjectEditor::GraphicsObjectEditor(QObject *parent) :
    AbstractEditor(parent)
{
}

bool GraphicsObjectEditor::init()
{
    m_view = new EditGraphicsObjectWidget;

    return true;
}

void GraphicsObjectEditor::activate()
{
    AbstractEditor::activate();

    QPointer<GraphicsObject> go = qobject_cast<GraphicsObject*>(Application::app().document()->currentObject());
    Q_ASSERT(go);

    EditGraphicsObjectWidget* pView = qobject_cast<EditGraphicsObjectWidget*>(m_view);
    Q_ASSERT(pView);

    bool toEnableECS = false;
    if(go->hasTexture())
    {
        toEnableECS = true;
    }
    else if(go->hasAnimations())
    {
        // TODO: add more complex logic for checking
        toEnableECS = true;
    }

    pView->enableEditCollisionShapes(toEnableECS);
}

